//
// Project: Disagreement in science: Missing women



clear all
version 15.1  



//
// set locals

// method of identifying female variable
local female "female_genderize"

// gender of author is known
local known_gender "female_genderize!=."




//
// Biorxiv

// call data
use "${data}/output/biorxiv_gender.dta", clear

// prepare for analysis
by article_id, sort: egen number_authors = count(article_id)
generate solo_authored = number_authors==1

 
//
// analysis

// baseline
local i=1
local coefficients`i' "1 2"
regress `female' ib3.results_type_id if `known_gender' & solo_authored, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)

// subject FE
local i=2
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id if `known_gender' & solo_authored, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)

// subject and year FE
local i=3
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id i.year if `known_gender' & solo_authored, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)




//
// significance stars for regressions above
forvalues j=1/3 {
	foreach k of numlist `coefficients`j'' {
		if `p`j'_`k''<0.1 & `p`j'_`k''>=0.05 {
			scalar st`j'_`k'="*"
		}
		else if `p`j'_`k''<0.05 & `p`j'_`k''>=0.01 {
			scalar st`j'_`k'="**"
		}
		else if `p`j'_`k''<0.01 & `p`j'_`k''>=0.001 {
			scalar st`j'_`k'="***"
		}
		else if `p`j'_`k''<0.001 {
			scalar st`j'_`k'="****"
		}
		else {
			scalar st`j'_`k'=""
		}
	}
}
	




